{include file="common/_meta" /}
<title>商品管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 商品管理 <span class="c-gray en">&gt;</span> 商品列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		<form class="Huiform" method="get" action="" target="_self">
			<span class="select-box inline">
			<select name="status" class="select">
				<option value="">全部商品</option>
				<option value="1" class="c-green">在线</option>
				<option value="0">待审核</option>
				<option value="-1">已下架</option>
			</select>
			</span>
			<span class="select-box inline">
			<select name="cate_id" class="select">
				<option value="">全部分类</option>
				{volist name="cate" id="vo"}
					<option value="{$vo.id}">|—{$vo.cate_name}</option>
				{/volist}
			</select>
			</span>
			<input type="text" placeholder="" name="page" class="input-text hidden" style="width:200px" value="1">
			<input type="text" placeholder="商品名称" name="keywords" class="input-text" style="width:200px" value="{$Request.get.keywords|default=''}">
			<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe709;</i> 搜索</button>
		</form>

	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
	<!-- <a class="btn btn-primary radius" onclick="product_edit('添加产品','add')" href="javascript:;"><i class="Hui-iconfont"></i> 添加产品</a>  -->
	<span class="r">共有数据：<strong>{$list->total()}</strong> 条</span> </div>
	<div class="mt-20">
		<table class="table table-border table-hover  table-bg table-sort">
			<thead>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th>商品ID</th>
					<th>商品分类</th>
					<th>商品图片</th>
					<th>商品名称</th>
					<th>商品单价</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				{volist name="list" id="vo"}
					<tr class="text-c">
						<td><input name="" type="checkbox" value=""></td>
						<td width="40px">{$vo.id}</td>
						<td>{$vo['goods_cate']['cate_name']}</td>
						<td><img  style="width: 40px;height: 40px" class="product-thumb image" src="{$vo.goods_pic}" alt=""></td>
						<td>{$vo.goods_name}
							{if condition="$vo.is_hot"}
								<span class="label label-danger round">热卖</span>
							{/if}
						</td>
						<td>{$vo['goods_sku'][0]['realprice']}</td>
						<td class="td-status">
						{if condition="$vo.status eq 1"}
							<span class="label label-success radius">在线</span>
						{elseif condition="$vo.status eq -1"}
							<span class="label label-error radius">已下架</span>
						{elseif condition="$vo.status eq 0"}
							<span class="label label-error radius">待审核</span>
						{/if}
						</td>
						<td class="f-14 td-manage">
						{if condition="$vo.status eq 0"}
							<a style="text-decoration:none" onclick="object(this,{$vo.id},-2)" href="javascript:;" title="驳回申请"><i class="Hui-iconfont">&#xe631;</i></a>
							&nbsp;&nbsp;&nbsp;
							<a style="text-decoration:none" onclick="optPro(this,{$vo.id},1)" href="javascript:;" title="审核通过"><i class="Hui-iconfont">&#xe6a7;</i></a> 
						{elseif condition="$vo.status eq 1"}
							<a style="text-decoration:none" onclick="optPro(this,{$vo.id},-1)" href="javascript:;" title="商品下架"><i class="Hui-iconfont">&#xe631;</i></a>

							&nbsp;&nbsp;&nbsp;
							{if condition="$vo.is_hot eq 1"}
							<a style="text-decoration:none" onclick="setHot(this,{$vo.id},0)" href="javascript:;"  title="取消热销"><i class="Hui-iconfont">&#xe6e4;</i></a>
							{else /}
							<a style="text-decoration:none" onclick="setHot(this,{$vo.id},1)" href="javascript:;"  title="设为热销"><i class="Hui-iconfont">&#xe6c3;</i></a>
							{/if}

						{elseif condition="$vo.status eq -1"}
							<a style="text-decoration:none" onclick="optPro(this,{$vo.id},1)" href="javascript:;" title="商品上线"><i class="Hui-iconfont">&#xe6a7;</i></a> 
						{else/}
						{/if}
						&nbsp;&nbsp;&nbsp;
						<a style="text-decoration:none" href="{:url('Mall/addGoods')}?id={$vo.id}"  title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> 
						</td>
					</tr>
				{/volist}
			</tbody>
		</table>
		<div class="pages" style="margin:20px;float: right; ">{$list->render()}</div>
	</div>
</div>

{include file="common/_footer" /}
<script type="text/javascript">
$('form select[name="cate_id"]').val({$Request.get.cate_id});
$('form select[name="status"]').val({$Request.get.status});
function optPro(obj,id,status){
	$(obj).attr('disabled',true);
	$.post("{:url('Mall/goods')}?act=opt",{id:id,status:status}).success(function(data){
		layer.msg(data.msg);
		if(data.code){
			setTimeout(function(){
				history.go(0);
			},500);
		} 
	});
}


function object(obj, id, status) {
	layer.prompt({
		  formType: 2,
		  title: '驳回申请，填写理由'
		},
	function(val, index){
		var note = val;

		$.post("{:url('Mall/goods')}?act=opt",{id:id,status:status,note:note}).success(function(data){
			layer.msg(data.msg);
			if(data.code){
				setTimeout(function(){
					history.go(0);
				},500);
			}
		});
	});
}


function setHot(obj,id,status){
	// $(obj).attr('disabled',true);
	$.post("{:url('Mall/goods')}?act=hot",{id:id,status:status}).success(function(data){
		layer.msg(data.msg);
		if(data.code){
			setTimeout(function(){
				history.go(0);
			},500);
		}
	});
}

</script>
</body>
</html>